#pragma strict

function Start () {

}
var mat:Material;
var loopTime:float;
var direction = "";

function Update () {
	var offset:float = Mathf.Repeat (Time.time/loopTime,1);
	var frames = loopTime/Time.deltaTime;
	//var offset:float = 1/frames;
	//offset = Mathf.FloorToInt(offset*frames)/frames;
	//offset = Mathf.FloorToInt(offset*60)/60.0f;
	
	//Debug.Log("offset: "+offset);
	//Debug.Log(frames);
 
	//mat.mainTextureOffset.x = -offset;
	if(direction =="x")
		mat.SetTextureOffset("_MainTex", new Vector2(offset,0));
	if(direction =="-x")
		mat.SetTextureOffset("_MainTex", new Vector2(-offset,0));
	if(direction =="y")
		mat.SetTextureOffset("_MainTex", new Vector2(0,offset));
	if(direction =="-y")
		mat.SetTextureOffset("_MainTex", new Vector2(0,-offset));
}